<?php
require(dirname(__FILE__).'\PageIndex.class.php');
class PageView{
	/** 页码开始索引和结束索引 **/
	var $pageindex;
	/** 总页数 **/
	var $totalpage = 1;
	/** 每页显示记录数 **/
	var $maxresult = 10;
	/** 当前页 **/
	var $currentpage = 1;
	/** 总记录数 **/
	var $totalrecord;
	/** 页码数量 **/
	var $pagecode = 10;
	
	function __construct($currentpage,$totalrecord,$maxresult=10,$pagecode=10) {
		$this->maxresult = $maxresult;
		$this->currentpage = $currentpage;
		$this->totalrecord = $totalrecord;
		$this->pagecode = $pagecode;
		$this->totalpage = $this->totalrecord%$this->maxresult==0? intval($this->totalrecord/$this->maxresult) :  intval($this->totalrecord/$this->maxresult)+1;
		$this->pageindex = PageIndex::getPageIndex($this->pagecode, $this->currentpage, $this->totalpage);
	}
	/** 要获取记录的开始索引 **/
	public function getFirstResult() {
		return ($this->currentpage-1)*$this->maxresult;
	}
}
?>